home *** CD-ROM | disk | FTP | other *** search
- class smashing.ClipHandler
- {
- var offset;
- var home;
- var clips;
- var openSlots;
- var id;
- static var nId = 0;
- function ClipHandler(objHome, nOffset)
- {
- if(nOffset == undefined)
- {
- nOffset = 0;
- }
- this.offset = nOffset;
- this.home = objHome;
- this.clips = [];
- this.openSlots = [];
- this.id = smashing.ClipHandler.nId++;
- }
- function findFirstEmpty()
- {
- var _loc2_ = 0;
- if(this.openSlots.length == 0)
- {
- _loc2_ = this.clips.length;
- }
- else
- {
- _loc2_ = this.openSlots.pop();
- }
- return _loc2_;
- }
- function addClip(sName)
- {
- var _loc2_ = this.findFirstEmpty();
- if(this.clips[_loc2_] != null)
- {
- }
- var _loc4_ = _loc2_ + this.offset;
- var _loc0_ = null;
- var _loc3_ = this.clips[_loc2_] = this.home.attachMovie(sName,"clip" + _loc2_ + Math.floor(60000 * Math.random()),_loc4_);
- _loc3_.nId = _loc2_;
- _loc3_.handler = this;
- return this.clips[_loc2_];
- }
- function removeClip(mc)
- {
- if(mc.handler != null)
- {
- if(mc.handler.id == this.id)
- {
- var _loc2_ = mc.nId;
- this.openSlots.push(_loc2_);
- this.clips[_loc2_].removeMovieClip();
- this.clips[_loc2_] = null;
- return true;
- }
- }
- return false;
- }
- function removeIndex(nIndex)
- {
- if(this.clips[nIndex] != null)
- {
- this.openSlots.push(nIndex);
- this.clips[nIndex].removeMovieClip();
- this.clips[nIndex] = null;
- return true;
- }
- return false;
- }
- function swap(nFirst, nSecond)
- {
- if(this.clips[nFirst] != null && this.clips[nSecond] != null)
- {
- var _loc4_ = this.clips[nFirst];
- this.clips[nFirst] = this.clips[nSecond];
- this.clips[nSecond] = _loc4_;
- this.clips[nFirst].swapDepths(this.clips[nSecond]._name);
- }
- }
- function removeAllClips()
- {
- var _loc2_ = 0;
- while(_loc2_ < this.clips.length)
- {
- this.removeIndex(_loc2_);
- _loc2_ = _loc2_ + 1;
- }
- }
- function toString()
- {
- return "[Cliphandler id:" + this.id + "]";
- }
- }
-